/**
 * 
 */
package com.ssyt.lms.sys.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ssyt.lms.entity.UserInfo;
import com.ssyt.lms.sys.constant.SystemConstant;
import com.ssyt.lms.sys.dao.UserInfoMapper;

/**
 * @author Administrator
 * @since 2016年5月25日
 */
@Service("userService")
@Transactional // 启用事务控制
public class UserInfoServiceImpl implements IUserInfoService,SystemConstant {

	@Autowired
	@Qualifier("userMapper")
	private UserInfoMapper userMapper;
	
	/* (non-Javadoc)
	 * @see com.ssyt.lms.sys.service.IUserInfoService#login(com.ssyt.lms.entity.UserInfo)
	 */
	@Override
	public UserInfo login(UserInfo user) {
		try {
			user = userMapper.login(user);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return user; 
	}

	@Override
	public List<UserInfo> listUserInfo(UserInfo user) {
		
		return userMapper.listUserInfo(user);
	}

	@Override
	public Integer updateUserById(UserInfo user) {
		
		return userMapper.updateUserById(user);
	}

	@Override
	public UserInfo selectUserInfoById(UserInfo user) {
		
		return userMapper.selectUserInfoById(user);
	}

	@Override
	public Integer updateUserInfo(UserInfo user) {
		if ("0".equals(user.getResetPassword())) {
			user.setPassword(DEFAULT_PASSWORD);
		}
		return userMapper.updateUserInfo(user);
	}

	@Override
	public Integer addUserInfo(UserInfo user) {
		
		return userMapper.addUserInfo(user);
	}

}
